Skip to content

fix(ci): import profiler ci setuptools - #17713

Closed
hebaalazzeh wants to merge 48 commits into
mainfrom
feat/fix-import-profiler-setuptools
Closed

fix(ci): import profiler ci setuptools#17713
hebaalazzeh wants to merge 48 commits into
mainfrom
feat/fix-import-profiler-setuptools

Conversation

@hebaalazzeh

Copy link
Copy Markdown
Contributor

Error

The import-profile CI workflow fails on Python 3.15 with:

ModuleNotFoundError: No module named 'google.cloud.api'. Did you mean: 'google.cloud.location'?

This PR installs setuptools inside the temporary .venv-profiler virtualenv created for profiling. This ensures the profiler's namespace package resolution logic works correctly on newer Python versions (3.12+) where setuptools is no longer installed by default.

hebaalazzeh and others added 30 commits June 30, 2026 06:42
…rs.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Splits the monolithic client_helpers.py into routing.py, client_cert.py, config_helpers.py, and method_helpers.py to improve readability and maintainability.
Updates gapic_v1 exports and test imports accordingly.
hebaalazzeh and others added 17 commits July 13, 2026 16:55
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
…ers.py

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
@hebaalazzeh hebaalazzeh changed the title fix: import profiler ci setuptools fix(ci): import profiler ci setuptools Jul 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several helper modules under google/api_core/gapic_v1 to handle client certificates, environment variable parsing, request ID generation, and routing/endpoint resolution for mTLS and universe domains, along with comprehensive unit tests. The feedback suggests raising a MutualTLSChannelError in _get_client_cert_source if mTLS is enabled but no client certificate source is provided or found, rather than silently falling back to standard TLS.

Comment on lines +70 to +79
client_cert_source = None
if use_cert_flag:
if provided_cert_source:
client_cert_source = provided_cert_source
elif (
hasattr(mtls, "has_default_client_cert_source")
and mtls.has_default_client_cert_source()
):
client_cert_source = mtls.default_client_cert_source()
return client_cert_source

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

According to the general rules, we should not silently fall back to standard TLS if mutual TLS (mTLS) configuration or certificate loading fails. If use_cert_flag is True but no client certificate source can be found (neither provided nor default), we should raise a MutualTLSChannelError to fail fast and avoid security risks or confusing downstream authorization errors.

Suggested change
client_cert_source = None
if use_cert_flag:
if provided_cert_source:
client_cert_source = provided_cert_source
elif (
hasattr(mtls, "has_default_client_cert_source")
and mtls.has_default_client_cert_source()
):
client_cert_source = mtls.default_client_cert_source()
return client_cert_source
client_cert_source = None
if use_cert_flag:
if provided_cert_source:
client_cert_source = provided_cert_source
elif (
hasattr(mtls, "has_default_client_cert_source")
and mtls.has_default_client_cert_source()
):
client_cert_source = mtls.default_client_cert_source()
else:
from google.auth.exceptions import MutualTLSChannelError
raise MutualTLSChannelError(
"Client certificate source is required when mTLS is enabled, "
"but no client certificate source was provided or found."
)
return client_cert_source
References
  1. Do not silently fall back to standard TLS if mutual TLS (mTLS) configuration or certificate loading fails. Silently falling back can introduce security vulnerabilities or cause confusing downstream authorization errors; instead, fail fast by raising an appropriate exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant